package cn.ydw.community.entity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

@Data
public class PageDTO {
    private Page<?> page;
    private Long from;  // 页码显示的头
    private Long to; // 页码显示的尾
    private String path; //路径

    private long offset; //每页起始索引

    public PageDTO(Page<?> page) {
        this.page = page;
    }
    public PageDTO pageDTO(){
        offset = (page.getCurrent() - 1) * page.getSize();
        from = page.getCurrent() - 3L;
        if(from < 1L){
            from = 1L;
        }
        to = page.getCurrent() + 3L;
        if (to > page.getPages()){
            to = page.getPages();
        }
        return this;
    }
}
